package org.ruoyi.dhuman.utils;

import org.ruoyi.common.core.utils.StringUtils;
import org.ruoyi.dhuman.vo.SubInfoVo;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class FFmpegUtils {

//	FFmpeg 的 -preset 参数 🎛️ 主要用于平衡视频编码速度和压缩效率（最终影响视频质量）。预设值从 ultrafast 到 placebo，编码速度依次递减，压缩效率则通常更高，这意味在相同码率下可能获得更好的视频质量，或者以更小的文件大小获得同等观感质量。
//
//	下面这个表格整理了 libx264 和 libx265 编码器常用的 -preset 选项及其含义，你可以根据需求选择。
//			预设值	编码速度	压缩效率/质量倾向	适用场景举例
	public enum Preset {
		// 最快 ⚡	较低	实时屏幕录制、快速预览
		ultrafast,
		// 非常快	较低	需要快速编码的场景
		superfast,
		// 很快	稍低	编码速度优先于质量的场景
		veryfast,
		// 较快	适中	需要较快编码速度的场景
		faster,
		// 快	适中	平衡速度和质量的场景。
		fast,
		// 默认值，适中 ⚖️	均衡	通用场景，无特殊要求时的选择。
		medium,
		// 较慢	较好	对质量有较高要求时。
		slow,
		// 慢	好	你当前使用的选项，追求较好质量。
		slower,
		// 非常慢 🐌	非常好	追求极致压缩率，不关心编码时间。
		veryslow,
		// 极慢 🐌极慢（可忽略）	极微提升	通常不推荐使用，编码耗时极长且质量提升微乎其
		placebo;
	}

//	/**
//	 * 执行命令
//	 *
//	 * @param command 命令列表
//	 * @throws IOException          IO异常
//	 * @throws InterruptedException 中断异常
//	 */
//	private static void executeCommand(List<String> command) throws IOException, InterruptedException {
//		System.out.println("执行命令: " + String.join(" ", command));
//
//		ProcessBuilder processBuilder = new ProcessBuilder(command);
//		processBuilder.redirectErrorStream(true);
//		Process process = processBuilder.start();
//
//		BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//		String line;
//		while ((line = reader.readLine()) != null) {
//			System.out.println(line);
//		}
//
//		int exitCode = process.waitFor();
//		System.out.println("FFmpeg处理完成，退出码: " + exitCode);
//		if (exitCode != 0) {
//			throw new RuntimeException("FFmpeg处理失败，退出码: " + exitCode);
//		}
//	}

	private static String fenbiaolv = "1600:900";

	public static boolean executeFfmpegBaseCommand(String pptImagePath,
												   double duration,
												   String outputPath)
		throws IOException, InterruptedException {

		// ffmpeg -loop 1 -i "C:\Users\Admin\Videos\dhumanImage.png" -t 1 -vf "scale=1920:1080:force_original_aspect_ratio=disable" -c:v libx264 -pix_fmt yuv420p -r 25 -y "C:\Users\Admin\Videos\dhuman_video.mp4"
		// ffmpeg -loop 1 -i "C:\Users\Admin\Videos\dhumanImage.png" -f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=44100" -t 1 -vf "scale=1920:1080:force_original_aspect_ratio=disable" -c:v libx264 -pix_fmt yuv420p -r 25 -c:a aac -b:a 192k -shortest -y "C:\Users\Admin\Videos\dhuman_video.mp4"

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-loop"); command.add("1");
		command.add("-i"); command.add(pptImagePath);
		command.add("-f");
		command.add("lavfi");
		command.add("-i");
		command.add("\"anullsrc=channel_layout=stereo:sample_rate=44100\"");
		command.add("-t"); command.add(Double.toString(duration));
		command.add("-vf");
		command.add("\"scale=" + fenbiaolv + ":force_original_aspect_ratio=disable\"");
		command.add("-c:v");
		command.add("libx264");
		command.add("-pix_fmt"); command.add("yuv420p");
		command.add("-r"); command.add("25");
		command.add("-c:a");
		command.add("aac");
		command.add("-b:a");
		command.add("192k");
		command.add("-shortest");
		command.add("-y");
		command.add(outputPath);

		return executeCommand(command);
	}

	public static boolean executeFfmpegBaseCommand(String bgImagePath,
											   String pptImagePath, String pptArea, String pptXY,
											   double duration,
											   String outputPath)
		throws IOException, InterruptedException {

		/*
		ffmpeg
			-loop 1 -i "C:\Users\Admin\Videos\合并\20251104.111249.109\subPPT_0\bg_4688732256200560641.png"
			-loop 1 -i "C:\Users\Admin\Videos\合并\20251104.111249.109\subPPT_0\ppt_45653ce161094ccc9037f92ce216a0ad.png"
			-f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=44100"
			-filter_complex "[0:v]scale=1600:900:force_original_aspect_ratio=increase,crop=1600:900,format=yuv420p[bg];[1:v]scale=960:540:force_original_aspect_ratio=decrease[ppt];[bg][ppt]overlay=475.0:145.0:format=auto[v]"
			-map "[v]" -map 2:a -t 1.0 -s 1600:900 -r 25 -pix_fmt yuv420p -c:a aac -b:a 192k -y "C:\Users\Admin\Videos\合并\20251104.111249.109\subPPT_0\output_base.mp4"
		*/

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-loop"); command.add("1");
		command.add("-i"); command.add(bgImagePath);
		command.add("-loop"); command.add("1");
		command.add("-i"); command.add(pptImagePath);
		command.add("-f");
		command.add("lavfi");
		command.add("-i");
		command.add("\"anullsrc=channel_layout=stereo:sample_rate=44100\"");
		command.add("-filter_complex");
		command.add("\"[0:v]scale=" + fenbiaolv + ":force_original_aspect_ratio=increase,crop=" + fenbiaolv + ",format=yuv420p[bg];[1:v]scale=" + pptArea + ":force_original_aspect_ratio=decrease[ppt];[bg][ppt]overlay=" + pptXY + ":format=auto\"[v]");
		command.add("-map");
		command.add("\"[v]\"");
		command.add("-map");
		command.add("2:a");
		command.add("-t"); command.add(Double.toString(duration));
		command.add("-s"); command.add(fenbiaolv);
		command.add("-r"); command.add("25");
		command.add("-pix_fmt"); command.add("yuv420p");
		command.add("-c:a");
		command.add("aac");
		command.add("-b:a");
		command.add("192k");
		command.add("-y");
		command.add(outputPath);

		return executeCommand(command);
	}

	public static boolean executeFfmpegDhumanCommand(String baseVideoPath,
												   String videoPath,
												   String videoMaskPath,
												   String videoArea,
												   String videoXY,
												   String outputPath)
		throws IOException, InterruptedException {

		// ffmpeg
		// -i "C:\Users\Admin\Videos\合并\20251031.113000.284\subPPT_0\output_base.mp4"
		// -i "C:\Users\Admin\Videos\合并\20251031.113000.284\subPPT_0\dhuman_video_result.mp4"
		// -i "C:\Users\Admin\Videos\合并\20251031.113000.284\subPPT_0\dhuman_video_mask_mask.mp4"
		// -filter_complex
		// "[1:v]setpts=PTS-STARTPTS[human]; [2:v]setpts=PTS-STARTPTS[mask]; [human][mask]alphamerge,format=rgba[fg_with_alpha]; [0:v]scale=iw:ih[bg]; [fg_with_alpha]scale=720:1280[fg_scaled]; [bg][fg_scaled]overlay=-110.0:120.0"
		// -c:v libx264 -crf 18 -preset slower -pix_fmt yuv420p -c:a aac -b:a 192k
		// -y "C:\Users\Admin\Videos\合并\20251031.113000.284\subPPT_0\output_dhuman.mp4"

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-i"); command.add(baseVideoPath);
		command.add("-i"); command.add(videoPath);
		command.add("-i"); command.add(videoMaskPath);
		command.add("-filter_complex");
		command.add("\"[1:v]setpts=PTS-STARTPTS[human]; [2:v]setpts=PTS-STARTPTS[mask]; [human][mask]alphamerge,format=rgba[fg_with_alpha]; [0:v]scale=iw:ih[bg]; [fg_with_alpha]scale=" + videoArea + "[fg_scaled]; [bg][fg_scaled]overlay=" + videoXY + "\"");
//		command.add("[1:v][2:v]alphamerge,format=rgba[fg_with_alpha]; [0:v]scale=iw:ih[bg]; [fg_with_alpha]scale=" + videoArea + "[fg_scaled]; [bg][fg_scaled]overlay=" + videoXY + ":format=yuv420");
		command.add("-c:v");
		command.add("libx264");
		command.add("-crf");
		command.add("18");
		command.add("-preset");
		command.add("slower");
		command.add("-pix_fmt");
		command.add("yuv420p");
		command.add("-c:a"); command.add("aac");
		command.add("-b:a"); command.add("192k");
		command.add("-y");
		command.add(outputPath);

		return executeCommand(command);
	}

	public static boolean executeFfmpegTTSCommand(String videoPath,
												  String audioPath,
												  String outputPath)
		throws IOException, InterruptedException {

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-i"); command.add(videoPath);
		command.add("-i"); command.add(audioPath);
		command.add("-c");
		command.add("copy");
		command.add("-y");
		command.add(outputPath);

		return executeCommand(command);

//		ProcessBuilder pb = new ProcessBuilder(command);
//		// 可选：将输出重定向到控制台以便调试
//		// pb.inheritIO();
//
//		Process process = pb.start();
//
//		// 处理输出流，防止进程阻塞
//		clearStream(process.getInputStream(), false);
//		clearStream(process.getErrorStream(), true);
//
//		int exitCode = process.waitFor();
//		return exitCode == 0;
	}

//	public static boolean executeFfmpegCommand(String bgImagePath,
//											   String pptImagePath, String pptArea, String pptXY,
//											   String dhumanImagePath, String dhumanArea, String dhumanXY,
//											   String duration,
//											   String outputPath)
//		throws IOException, InterruptedException {
//
//		// 构建命令参数列表
//		List<String> command = new ArrayList<>();
//		command.add("ffmpeg");
//		command.add("-loop"); command.add("1");
//		command.add("-i"); command.add(bgImagePath);
//		command.add("-loop"); command.add("1");
//		command.add("-i"); command.add(pptImagePath);
//		command.add("-loop"); command.add("1");
//		command.add("-i"); command.add(dhumanImagePath);
//		command.add("-filter_complex");
//		command.add("[0]scale=1920:1080:force_original_aspect_ratio=disable[bg];[1]scale=" + pptArea + ":force_original_aspect_ratio=disable[ppt];[2]scale=" + dhumanArea + ":force_original_aspect_ratio=disable[human];[bg][ppt]overlay=" + pptXY + "[tmp];[tmp][human]overlay=" + dhumanXY + ":shortest=1");
//		command.add("-t"); command.add(duration);
//		command.add("-r"); command.add("25");
//		command.add("-pix_fmt"); command.add("yuv420p");
//		command.add("-y");
//		command.add(outputPath);
//
//		return executeCommand(command);

//		ProcessBuilder pb = new ProcessBuilder(command);
//		// 可选：将输出重定向到控制台以便调试
//		// pb.inheritIO();
//
//		Process process = pb.start();
//
//		// 处理输出流，防止进程阻塞
//		clearStream(process.getInputStream(), false);
//		clearStream(process.getErrorStream(), true);
//
//		int exitCode = process.waitFor();
//		return exitCode == 0;
//	}

	public static boolean executeConcatImageCommand(String videoFilePath, String dhumanInageFilePath, String dhmanArea, String dhumanXY, String outputFilePath)
		throws IOException, InterruptedException {

		// ffmpeg -i background.mp4 -i background.png -filter_complex "[1:v]scale=1200:600[img];[0:v][img]overlay=50:150" -c:v libx264 -crf 18 -preset slower -pix_fmt yuv420p -c:a copy -y background_image.mp4

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-i");
		command.add(videoFilePath);
		command.add("-i");
		command.add(dhumanInageFilePath);
		command.add("-filter_complex");
		command.add("\"[1:v]scale=" + dhmanArea + "[img];[0:v][img]overlay=" + dhumanXY + "\"");
		command.add("-c:v");
		command.add("libx264");
		command.add("-crf");
		command.add("18");
		command.add("-preset");
		command.add("slower");
		command.add("-pix_fmt");
		command.add("yuv420p");
		command.add("-c:a");
		command.add("copy");
		command.add("-y");
		command.add(outputFilePath);

		return executeCommand(command);
	}


	public static boolean executeTTSCommand(String videoFilePath, String audioFilePath, String subtitlesFilePath, String subtitlesStyle, String outputFilePath)
		throws IOException, InterruptedException {

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		if (StringUtils.isNotEmpty(subtitlesFilePath)) {
			// ffmpeg
			// ffmpeg
			// -i "output_dhuman.mp4"
			// -i "audio.mp3"
			// -filter_complex
			// "[0:v]loop=-1:1:0,setpts=N/FRAME_RATE/TB[tempv]; [tempv]subtitles='srt_create.srt':force_style='Alignment=2,MarginV=50,Fontsize=20'[outv]"
			// -map "[outv]" -map "1:a" -c:v libx264 -crf 18 -preset slower -c:a aac -b:a 192k
			// -shortest
			// -y "output_final.mp4"

			// window 环境下盘符转义，先转\再转:
			subtitlesFilePath = subtitlesFilePath.replace("\\", "\\\\");
			subtitlesFilePath = subtitlesFilePath.replace(":", "\\:");

			// 添加字幕
			command.add("ffmpeg");
			command.add("-i");
			command.add(videoFilePath);
			command.add("-i");
			command.add(audioFilePath);
			command.add("-filter_complex");
			command.add("\"[0:v]loop=-1:1:0,setpts=N/FRAME_RATE/TB[tempv]; [tempv]subtitles='" + subtitlesFilePath + "':force_style='" + subtitlesStyle + "'[outv]\"");
			command.add("-map");
			command.add("\"[outv]\"");
			command.add("-map");
			command.add("1:a");
			command.add("-c:v");
			command.add("libx264");
			command.add("-crf");
			command.add("18");
			command.add("-preset");
			command.add(Preset.ultrafast.toString());
			command.add("-c:a");
			command.add("aac");
			command.add("-b:a");
			command.add("192k");
			command.add("-shortest");
			command.add("-y");
			command.add(outputFilePath);
		} else if (StringUtils.isNotEmpty(audioFilePath)) {
			command.add("ffmpeg");
			command.add("-i");
			command.add(videoFilePath);
			command.add("-i");
			command.add(audioFilePath);
			command.add("-map");
			command.add("0:v:0");
			command.add("-map");
			command.add("1:a:0");
			command.add("-c:v");
			command.add("copy");
			command.add("-c:a");
			command.add("copy");
			command.add("-y");
			command.add(outputFilePath);
		}

		return executeCommand(command);
	}

	public static boolean executeZimuCommand(String videoFilePath, String subtitlesFilePath, String subtitlesStyle, String outputFilePath)
		throws IOException, InterruptedException {

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		// ffmpeg -i background.mp4 -filter_complex "subtitles=hanlu.srt:force_style='FontName=Microsoft YaHei,Fontsize=24,PrimaryColour=&HFFFFFF,OutlineColour=&H000000,BorderStyle=1,Outline=1,Shadow=1,Alignment=2,MarginV=50'" -c:v libx264 -crf 18 -preset slower -c:a aac -b:a 192k -y output_hard_styled.mp4

		// window 环境下盘符转义，先转\再转:
		subtitlesFilePath = subtitlesFilePath.replace("\\", "\\\\");
		subtitlesFilePath = subtitlesFilePath.replace(":", "\\:");
		// 添加字幕
		command.add("ffmpeg");
		command.add("-i");
		command.add(videoFilePath);
		command.add("-filter_complex");
		command.add("\"[0:v]subtitles='" + subtitlesFilePath + "':force_style='" + subtitlesStyle + "'\"");
		command.add("-c:v");
		command.add("libx264");
		command.add("-crf");
		command.add("18");
		command.add("-preset");
		command.add("slower");
		command.add("-c:a");
		command.add("aac");
		command.add("-b:a");
		command.add("192k");
		command.add("-y");
		command.add(outputFilePath);

		return executeCommand(command);
	}

	public static boolean executeConcatCommand(String filelistFilePath, String outputFilePath)
		throws IOException, InterruptedException {
		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-f");
		command.add("concat");
		command.add("-safe");
		command.add("0");
		command.add("-i");
		command.add(filelistFilePath);
		command.add("-c");
		command.add("copy");
		command.add(outputFilePath);

		return executeCommand(command);
	}

	@Deprecated
	public static boolean executeConcatCommand(List<SubInfoVo> list, String outputFilePath, Preset preset)
		throws IOException, InterruptedException {

		/*
		ffmpeg \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_0\output_dhuman.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_1\output_tts.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_2\output_tts.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_3\output_tts.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_4\output_tts.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_5\output_tts.mp4" \
		  -i "C:\Users\Admin\Videos\合并\20251027.191322.462\subPPT_6\output_tts.mp4" \
		  -filter_complex \
			"[0:v]tpad=stop_mode=clone:stop_duration=10[v0]; \
			 [0:a]apad=pad_dur=10[a0]; \
			 [1:v]tpad=stop_mode=clone:stop_duration=10[v1]; \
			 [1:a]apad=pad_dur=10[a1]; \
			 [2:v]tpad=stop_mode=clone:stop_duration=10[v2]; \
			 [2:a]apad=pad_dur=10[a2]; \
			 [3:v]tpad=stop_mode=clone:stop_duration=10[v3]; \
			 [3:a]apad=pad_dur=10[a3]; \
			 [4:v]tpad=stop_mode=clone:stop_duration=10[v4]; \
			 [4:a]apad=pad_dur=10[a4]; \
			 [5:v]tpad=stop_mode=clone:stop_duration=10[v5]; \
			 [5:a]apad=pad_dur=10[a5]; \
			 [6:v]tpad=stop_mode=clone:stop_duration=10[v6]; \
			 [6:a]apad=pad_dur=10[a6]; \
			 [v0][a0][v1][a1][v2][a2][v3][a3][v4][a4][v5][a5][v6][a6]concat=n=7:v=1:a=1[outv][outa]" \
		  -map "[outv]" -map "[outa]" \
		  -c:v libx264 -crf 18 -preset medium \
		  -c:a aac -b:a 192k \
		  -movflags +faststart \
		  -y "C:\Users\Admin\Videos\合并\20251027.191322.462\merged_with_pauses.mp4"
		 */

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		for (SubInfoVo vo : list) {
			command.add("-i");
			command.add(vo.getFile().getAbsolutePath());
		}
		command.add("-filter_complex");
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		for (int i = 0; i < list.size(); i++) {
			int delayed = 0;
			if (list.get(i).getDhumanExpression() != null) {
				Integer DelayedSeconds = list.get(i).getDhumanExpression().getDelayedSeconds();
				if (DelayedSeconds != null && DelayedSeconds > 0) {
					delayed = DelayedSeconds;
				}
			}
			sb1.append("[" + i + ":v]tpad=stop_mode=clone:stop_duration=" + delayed + "[v" + i + "];[" + i + ":a]apad=pad_dur=" + delayed + "[a" + i + "];");
			sb2.append("[v" + i + "][a" + i + "]");
		}
		sb2.append("concat=n=" + list.size() + ":v=1:a=1[outv][outa]");


		command.add("\"" + sb1.toString() + sb2.toString() + "\"");
		command.add("-map");
		command.add("\"[outv]\"");
		command.add("-map");
		command.add("\"[outa]\"");
		command.add("-c:v");
		command.add("libx264");
		command.add("-crf");
		command.add("18");
		command.add("-preset");
		command.add(preset.toString());
		command.add("-c:a");
		command.add("aac");
		command.add("-b:a");
		command.add("192k");
		command.add("-movflags");
		command.add("+faststart");
		command.add("-y");
		command.add(outputFilePath);

		return executeCommand(command);
	}

	@Deprecated
	public static boolean executeFixAudioCommand(String videoFilePath, String outputFilePath)
		throws IOException, InterruptedException {

		/*
		ffmpeg
		-i "input_video.mp4"
		-f lavfi -i "anullsrc=channel_layout=stereo:sample_rate=44100"
		-c:v copy -c:a aac -shortest -y "output_with_audio.mp4"
		 */

		// 构建命令参数列表
		List<String> command = new ArrayList<>();
		command.add("ffmpeg");
		command.add("-i");
		command.add(videoFilePath);
		command.add("lavfi");
		command.add("-i");
		command.add("\"anullsrc=channel_layout=stereo:sample_rate=44100\"");
		command.add("-c:v");
		command.add("copy");
		command.add("-c:a");
		command.add("aac");
		command.add("-shortest");
		command.add("-y");
		command.add(outputFilePath);

		return executeCommand(command);
	}

//	private static void clearStream(java.io.InputStream inputStream, boolean isError) {
//		new Thread(() -> {
//			try (BufferedReader reader = new BufferedReader(
//				new InputStreamReader(inputStream))) {
//				String line;
//				while ((line = reader.readLine()) != null) {
//					if (isError) {
//						System.err.println("FFmpeg: " + line);
//					}
//					// 标准输出通常不需要处理，但可以按需启用
//					// else {
//					//     System.out.println("FFmpeg: " + line);
//					// }
//				}
//			} catch (IOException e) {
//				e.printStackTrace();
//			}
//		}).start();
//	}

	private static boolean executeCommand(List<String> command) throws IOException, InterruptedException {
		if (command == null || command.size() == 0) {
			return false;
		}
		System.out.println("执行命令: " + String.join(" ", command));

		ProcessBuilder pb = new ProcessBuilder(command);
		Process process = pb.start();

		// 处理标准输出
		Thread stdoutThread = new Thread(() -> {
			try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
				reader.lines().forEach(System.out::println);
			} catch (IOException e) {
				e.printStackTrace();
			}
		});

		// 处理错误输出
		Thread stderrThread = new Thread(() -> {
			try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
				reader.lines().forEach(System.err::println);
			} catch (IOException e) {
				e.printStackTrace();
			}
		});

		stdoutThread.start();
		stderrThread.start();

// 等待进程以及流的线程结束
		stdoutThread.join();
		stderrThread.join();
		int exitCode = process.waitFor();
		return exitCode == 0;
	}

	public static void main(String[] args) {
//		String workpath = "C:\\Users\\Admin\\Videos\\ffmpeg";
//		String timestamp = new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS").format(new java.util.Date());
//		String folderPath = workpath + "/" + timestamp;
//
		String bgImagePath = "C:\\Users\\Admin\\Videos\\ffmpeg\\test\\bg.png";
		String pptImagePath = "C:\\Users\\Admin\\Videos\\ffmpeg\\test\\ppt1.png";
		String dhumanImagePath = "C:\\Users\\Admin\\Videos\\ffmpeg\\test\\dhuman.png";
		String outputPath = "C:\\Users\\Admin\\Videos\\ffmpeg\\test\\output.mp4";
		File file = new File(outputPath);
		System.out.println(file.getAbsolutePath());

//		try {
//			boolean success = executeFfmpegCommand(bgImagePath, pptImagePath, "1200:600", "50:50", dhumanImagePath, "400:800", "1250:450", "5", outputPath);
//			if (success) {
//				System.out.println("视频生成成功！");
//			} else {
//				System.out.println("视频生成失败！");
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}
}
